import 'package:flutter_pink_app/net/base/error.dart';
import 'package:flutter_pink_app/net/base/response.dart';
import '../net/index.dart';
import '../net/request/regist_request.dart';
import '../net/adater/dio_adapter.dart';

// 业务注册函数
Future<BaseResponse<void>> registAccount(
    String username, String password) async {
  final headerField = {
    'userName': username,
    'password': password,
  }; // 头信息对应字段
  final request = RegistRequest();
  // 设置头信息
  headerField.forEach((key, value) => request.setQueryParams(value, key));
  final network = NetworkCall.getInstance(adapter: DioAdapter());
  BaseResponse<void> res;
  try {
    res = await network.send<void>(request);
  } on BaseNetworkError catch (e) {
    e.expectedErrorLog();
    res = BaseResponse(
        data: e.data, statusCode: e.statusCode, message: e.message);
    print("${res.message},$e");
  }
  return res;
}
